From c059b77ffda2143e34ce0a20decfc943de096f5b Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Wed, 12 Aug 2026 17:16:17 +0000 Subject: [PATCH] Always use the WATCHES.CommID when constructing SIGHTINGS from EVENTS --- .../functions/create/build_sightings.m4 | 30 ---------------- doc/src/functions/build_sightings.m4 | 34 +------------------ 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/db/schemas/sokwedb/functions/create/build_sightings.m4 b/db/schemas/sokwedb/functions/create/build_sightings.m4 index 89955da..f9895aa 100644 --- a/db/schemas/sokwedb/functions/create/build_sightings.m4 +++ b/db/schemas/sokwedb/functions/create/build_sightings.m4 @@ -161,36 +161,6 @@ CREATE OR REPLACE FUNCTION build_sightings(a_animid TEXT) AND roles.role = a_role; IF FOUND THEN - -- Determine the community - CASE a_behavior - WHEN 'sdb_utm' THEN - SELECT locations_utm.commid - INTO STRICT a_commid - FROM locations_utm - WHERE locations_utm.eid = a_eid; - WHEN 'sdb_paper' THEN - SELECT locations_paper.commid - INTO STRICT a_commid - FROM locations_paper - WHERE locations_paper.eid = a_eid; - WHEN 'sdb_aggression' THEN - SELECT aggressions.commid - INTO STRICT a_commid - FROM aggressions - WHERE aggressions.eid = a_eid; - WHEN 'sdb_mating' THEN - SELECT matings.commid - INTO STRICT a_commid - FROM matings - WHERE matings.eid = a_eid; - WHEN 'sdb_pg_event' THEN - SELECT pantgrunts.commid - INTO STRICT a_commid - FROM pantgrunts - WHERE pantgrunts.eid = a_eid; - ELSE NULL; -- Use obs.commid - END CASE; - do_insert := true; EXIT; END IF; diff --git a/doc/src/functions/build_sightings.m4 b/doc/src/functions/build_sightings.m4 index 28e3b2c..f741bca 100644 --- a/doc/src/functions/build_sightings.m4 +++ b/doc/src/functions/build_sightings.m4 @@ -103,39 +103,7 @@ how the community value is obtained: ``sdb_roles_sc`` - The community value used, if SIGHTING_CONTROLS.\ - |SIGHTING_CONTROLS.Behavior| is non-|null| and if such a value - exists, is the value contained in the table holding detail on the - event. - For example, aggression events, which have a ``sdb_aggression`` - |EVENTS|.\ |EVENTS.Behavior| value, are related to the - |AGGRESSIONS| table. - The |AGGRESSIONS| table has an |AGGRESSIONS|.\ |AGGRESSIONS.CommID| - column. - The value of the |AGGRESSIONS|.\ |AGGRESSIONS.CommID| column is - used for aggression events when an aggression event is found and - SIGHTING_CONTROLS.\ |SIGHTING_CONTROLS.Behavior| is - ``sdb_aggression``. - - When SIGHTING_CONTROLS.\ |SIGHTING_CONTROLS.Behavior| is |null|, or - when there is no community value in the detail associated with a - behavior, the |WATCHES|.\ |WATCHES.CommID| value is used. - - The "detail" tables with their own CommID column are: - - +--------------------+-------------------+ - | Behavior code | Table | - +====================+===================+ - | |spx_aggression| | |AGGRESSIONS| | - +--------------------+-------------------+ - | |spx_paper| | |LOCATIONS_PAPER| | - +--------------------+-------------------+ - | |spx_utm| | |LOCATIONS_UTM| | - +--------------------+-------------------+ - | |spx_mating_event| | |MATINGS| | - +--------------------+-------------------+ - | |spx_pg_event| | |PANTGRUNTS| | - +--------------------+-------------------+ + The |WATCHES|.\ |WATCHES.CommID| value is used. ``sdb_swelling_sources_sc`` -- 2.34.1